import React from 'react'
import {
  Form,
  Button,
  InputNumber,
  Input,
  TextArea,
} from '@nutui/nutui-react-taro'
import { changePasswordApi } from '../../../../servers/servers'
import Taro from "@tarojs/taro";

const password = () => {
  return (
    <>
      <Form
        labelPosition="right"
        footer={
          <>
            <Button formType="submit" block type="primary" size='xlarge'>
              提交
            </Button>
          </>
        }
        onFinish={async(values) => {
          try {
            await changePasswordApi({
              ...values
            })

            Taro.showToast({
              title: "修改成功，请重新登录",
              icon: "none",
              duration: 2000,
            });

            Taro.redirectTo({
              url: "/pages/login/index",
            });

            // 清空缓存
            Taro.clearStorage();

          } catch (error) {
            
          }
        }}
      >
        <Form.Item
          required
          label="修改密码"
          name="password"
          rules={[
            { required: true, message: '请输入新密码' },
          ]}
        >
          <Input
            className="nut-input-text"
            placeholder="请输入密码"
            type="password"
          />
        </Form.Item>
        
        
      </Form>
    </>
  )
}

export default password
